<?php

class Application_Model_Konsumen extends Zend_Db_Table_Abstract
{
    protected $_name = 'tabel_konsumen';
    
    public function konsumenBaru($data)
    {
        $this->insert($data);
    }
    
    
    public function konsumenUpdate($data, $id)
    {
        $this->update($data, 'id_konsumen = '.(int)$id);
    }
    
    public function konsumenDelete($id)
    {
        $this->delete('id_konsumen = '.(int)$id);
    }
    
    public function getAllData()
    {
        $data = $this->fetchAll()->toArray();
        return $data;
    }
    
    public function getDatabyId($id)
    {
        $row = $this->fetchRow('id_konsumen = '.(int)$id);
        if(!$row)
            return false;
        else
            return $row->toArray();
    }
    
    
    public function getData($id)
    {
        $select = $this->select();
        $select->setIntegrityCheck(false)
               ->from($this->_name)
               ->where('tabel_konsumen.id_konsumen = ?', $id);
        
        $result = $this->fetchAll($select);
        if($result)
            return $result->toArray ();
        else
            return false;
    }
    
    public function getDataKonsumen($id)
    {
        $select = $this->select();
        $select->setIntegrityCheck(false)
               ->from($this->_name)
               ->where('id_konsumen = ?', $id);
               
        $result = $this->fetchAll($select);
        if($result)
            return $result->toArray ();
        else
            return false;
    }
}

